package com.jinbiao.controller.start;

import javax.websocket.server.PathParam;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.jinbiao.service.user.UserService;

@RestController
@RequestMapping(value="/test")
public class UserController {
	
		@Autowired
	    private UserService userService;

	    @RequestMapping(value = "/getUser")
	    @ResponseBody
	    public String  getUser(@RequestParam("id")Integer id){
	    	
	        return userService.getUser(id).getId().toString();
	    }
	    
	    /**
	     * 采用rest 风格进行参数传递
	     * @param id
	     * @return
	     */
	    @RequestMapping(value="/getHello/{id}")
	    @ResponseBody
	    public String getHello(@PathVariable("id") Integer id) {
	    	
			return userService.getUser(id).toString()+"hello word";
	    }
	
}
